package com.sci99.ex;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.security.web.AuthenticationEntryPoint;

public class LoginUrlEntryPoint implements AuthenticationEntryPoint {

	Logger log = Logger.getLogger(LoginUrlEntryPoint.class);

	@Override
	public void commence(
			HttpServletRequest request,
			HttpServletResponse response,
			org.springframework.security.core.AuthenticationException authException)
			throws IOException, ServletException {
		String targetUrl = "/ex/index.zul";
		// String url = request.getRequestURI();

		// 取得登陆前的url
		String refererUrl = request.getHeader("Referer");
		if (refererUrl != null && !refererUrl.equals(targetUrl)) {
			targetUrl = refererUrl;

		}
	}
}